package com.ltcode.auth.infrastructure.remote.feign.factory;

import com.ltcode.auth.infrastructure.remote.feign.model.LoginUser;
import com.ltcode.auth.infrastructure.remote.feign.model.SysUserDTO;
import com.ltcode.auth.infrastructure.remote.feign.service.SysUserFeignService;
import com.ltcode.common.base.web.domain.ApiResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
@Slf4j
public class SysUserFeignFallBackFactory implements FallbackFactory<SysUserFeignService> {
    @Override
    public SysUserFeignService create(Throwable throwable) {
        log.error("用户服务调用失败:{}", throwable.getMessage());
        return new SysUserFeignService() {
            @Override
            public ApiResponse<Boolean> registerUser(SysUserDTO sysUser) {
                return ApiResponse.fail("注册用户失败");
            }

            @Override
            public ApiResponse<LoginUser> getUserInfo() {
                return ApiResponse.fail("获取用户信息失败");
            }

            @Override
            public ApiResponse<LoginUser> getUserInfo(String username) {
                return null;
            }

            @Override
            public ApiResponse<String> getUserInfo(Long userId) {
                return null;
            }

            @Override
            public ApiResponse<LoginUser> getUserInfoByEmail(String email) {
                return null;
            }

            @Override
            public ApiResponse<LoginUser> getUserInfoByPhone(String phone) {
                return null;
            }

            @Override
            public ApiResponse<Boolean> updateUserLoginInfo(Long userId, String loginIp) {
                return null;
            }

            @Override
            public ApiResponse<Boolean> updateUserPassword(Long userId, String password) {
                return null;
            }

            @Override
            public ApiResponse<Boolean> checkUserNameUnique(String username) {
                return null;
            }

            @Override
            public ApiResponse<Boolean> checkEmailUnique(String email) {
                return null;
            }

            @Override
            public ApiResponse<Boolean> checkPhoneUnique(String phone) {
                return null;
            }

            @Override
            public ApiResponse<Set<String>> getUserPermissions(Long userId) {
                return null;
            }

            @Override
            public ApiResponse<Set<String>> getUserRoles(Long userId) {
                return null;
            }
        };
    }
}
